Subject: Re: How to detach from cli.
From: [email-masked] (Christoph Feck IRZ)
Date: Tue, 8 Feb 1994 18:37:09 GMT
Newsgroups: comp.sys.amiga.programmer

In article <[email-masked]>, [email-masked] (Paul Toyne) writes:
> Cli detaching from assembler is very easy, and goes like follows :
> 
> 	Section	Start,CODE
> 
> _Start:
> 	; Check for WB startup, if so  Jmp _Program
> 
> 	; Open dos library
> 
> 	Lea	_Start(pc),a0
> 	Move.l	(a0),d3		; Pointer to segment list.
> 	Clr.l	(a0)		; Make dos think that this program
> 				;  only contains one hunk, so that it
> 				;  doesn't de-allocate the memory from
> 				;  our program.

This is VERY bad programming practise.  You should not touch the
segment list.

The correct way to do detaching (whatever reason you might have
to not use "run") is to NULL out the cli_Module pointer, and
start a new process with this segment and with a different
entry point (use CreateNewProc).

An example can be found in the source code to `term'.

3k// Christoph Feck, TowerSystems
\X/ Amiga - Intuition inside.